<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateTableUserCoupon extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_coupons', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('shop_id')->index()->nullable();
            $table->integer('user_id')->index();
            $table->integer('coupon_id')->index();
            $table->string('type');
            $table->string('title');
            $table->integer('price_limit');
            $table->integer('money');
            $table->jsonb('applicable')->nullable();
            $table->dateTime('expiration_date')->nullable()->index();
            $table->integer('use_id')->nullable()->index();
            $table->dateTime('use_time')->nullable();
            $table->integer('is_gift')->default(0);
            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_coupons');
    }
}
